#ifndef indexbuffer_h__
#define indexbuffer_h__
#include "../iindexbuffer.h"
#include <d3d9.h>

namespace gecko
{

// forward declare types
class IRenderer;
class Renderer_DirectX9;

class IndexBuffer_DirectX9 : public IIndexBuffer
{
public:
	// destructor
	virtual ~IndexBuffer_DirectX9();

	// Initialise the vertex buffer.
	bool Initialise(IRenderer *r, unsigned int indexCount, bool dynamic);

	// Lock the buffer prior to accessing index data.
	bool Lock(unsigned int offset, unsigned int indexCount, unsigned short** indices);

	//Unlock the buffer after accessing index data.
	bool Unlock();

	// Destroy the buffer and release resources.
	bool Destroy();

    bool OnResetDevice();

    bool OnLostDevice();

public:
    LPDIRECT3DINDEXBUFFER9 m_pIB;

private:
	// private contructor
	IndexBuffer_DirectX9();

    unsigned int		m_uiSize;
    bool				m_bDynamic;
    Renderer_DirectX9*	m_renderer;

	// allow renderer to new this up
	friend class Renderer_DirectX9;
};

}// namespace gecko

#endif // indexbuffer_h__
